if exists (select 1 from sysobjects where name = 'set_dienstserie' and type = 'P')
begin
   drop procedure set_dienstserie
   print 'Procedure: set_dienstserie deleted ...'
end
go
create procedure set_dienstserie(
  @PrsID             int           = 1,
  @dienstid          int           = 1,
  @AbteilungID       int           = 1,
  @Tag               int           = 1,
  @Typ               varchar(5)       = 'W',--M: Monat W: Woche
  @von               varchar(8)    = '20080101',
  @bis               varchar(8)    = '20100101'
--  @status            int
)
as
begin
  set nocount on

  declare @datevon datetime
  declare @datebis datetime

  select @datevon = convert(datetime, @von, 112)
  select @datebis = convert(datetime, @bis, 112)

  insert into dienstserie(prsid, dienstid, abteilungid, tag, typ, von, bis) values (@PrsID, @dienstid, @AbteilungID, @Tag, upper(@Typ), @datevon, @datebis)

end
go
print 'Procedure: set_dienstserie done ...'
go
grant exec on set_dienstserie to prsadmins with grant option
go
grant exec on set_dienstserie to prsusers
go

